home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / hardware / summa / sys / idev.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  28.9 KB  |  847 lines

  1. /*
  2.  * Copyright (C) 1990, 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17.  
  18. #ifndef IDEV_H
  19. #define    IDEV_H
  20.  
  21.     /*
  22.      * This header file includes some documentation for application
  23.      * writers and people supporting input devices.
  24.      */
  25.  
  26. /***====================================================================***/
  27. /***            DEFINES TO INTERPRET SHMIQ EVENTS        ***/
  28. /***====================================================================***/
  29.  
  30. #define    QE_PTR_EVENT    0
  31. #define QE_VAL_EVENT    1
  32. #define QE_BTN_EVENT    2
  33. #define    QE_PROX_EVENT    3
  34.  
  35.     /* bits in flags for pointer events (QE_RESPONSE, QE_GEN_PTR_X,
  36.      * and QE_GEN_PTR_Y are also used).
  37.      */
  38. #define    QE_X_CLAMPED    0x04
  39. #define    QE_Y_CLAMPED    0x08
  40.  
  41.     /* bits in flags for valuator events */
  42. #define QE_MORE_EVENTS    0x01    /* set if more val changes from this device are
  43.                    coming. */
  44. #define QE_RESPONSE    0x02    /* set if this event is the result of a 
  45.                    set or change valuator call. */
  46. #define QE_CLAMPED    0x04    /* set if the valuator is clamped to */
  47.                 /* its minimum or maximum value */
  48.  
  49.     /* bits in flags for button events */
  50. #define QE_BTN_DOWN    0x01    /* set in flags if button was pressed */
  51.  
  52.     /* bits in flags for proximity events */
  53. #define QE_PROX_IN    0x01    /* set if sensor moved into proximity */
  54.  
  55.  
  56.  
  57. #define    IDEVGETDEVICEDESC    _IOWR('i',0,idevDesc)
  58. #define    IDEVGETVALUATORDESC    _IOWR('i',1,idevGetSetValDesc)
  59. #define    IDEVGETKEYMAPDESC    _IOWR('i',2,idevKeymapDesc)
  60. #define    IDEVGETSTRDPYDESC    _IOWR('i',3,idevStrDpyDesc)
  61. #define    IDEVGETINTDPYDESC    _IOWR('i',4,idevIntDpyDesc)
  62.  
  63. #define    IDEVGETBUTTONS        _IOR('i',5,IDEV_MASK_SIZE)
  64. #define    IDEVGETVALUATORS    _IOR('i',6,idevValuatorState)
  65. #define    IDEVGETLEDS        _IOR('i',7,IDEV_MASK_SIZE)
  66. #define    IDEVGETSTRDPY        _IOR('i',8,idevStrDpyState)
  67. #define    IDEVGETINTDPYS        _IOR('i',9,idevIntDpyState)
  68.  
  69. #define    IDEVENABLEBUTTONS    _IOW('i',10,idevBitVals)
  70.  
  71. #define    IDEVENABLEVALUATORS    _IOW('i',11,idevBitVals)
  72. #define    IDEVSETVALUATORS    _IOW('i',12,idevValuatorState)
  73. #define    IDEVCHANGEVALUATORS    _IOW('i',13,idevValuatorState)
  74. #define    IDEVSETVALUATORDESC    _IOW('i',14,idevGetSetValDesc)
  75.  
  76. #define    IDEVSETLEDS        _IOW('i',15,idevBitVals)
  77. #define    IDEVSETSTRDPY         _IOW('i',16,idevStrDpyState)
  78. #define    IDEVSETINTDPYS        _IOW('i',17,idevIntDpyState)
  79. #define    IDEVRINGBELL        _IOW('i',18,idevBellSettings)
  80.  
  81. #define    IDEVKEYBDCONTROL    _IOWR('i',30,idevKeybdControl)
  82. #define    IDEVPTRCONTROL        _IOWR('i',31,idevPtrControl)
  83. #define    IDEVOTHERCONTROL    _IOWR('i',32,idevOtherControl)
  84. #define    IDEVSETPTRMODE        _IOW('i',33,idevPtrMode)
  85. #define    IDEVOTHERQUERY        _IOWR('i',34,idevOtherQuery)
  86. #define    IDEVSETPTRBOUNDS    _IOWR('i',35,idevPtrBounds)
  87. #define    IDEVSETPTR        _IOWR('i',36,idevPtrVals)
  88. #define    IDEVSETTRANSFORM    _IOWR('i',37,idevGetSetTransform)
  89. #define    IDEVGETTRANSFORM    _IOWR('i',38,idevGetSetTransform)
  90.  
  91. #define    IDEVINITDEVICE        _IOW('i',51,unsigned long)
  92.  
  93.  
  94. #define    IDEV_MAX_BUTTONS    256
  95. #define    IDEV_MAX_VALUATORS    256
  96. #define    IDEV_MAX_LEDS        256
  97. #define    IDEV_MAX_STR_DPYS    256
  98. #define    IDEV_MAX_INT_DPYS    256
  99.  
  100. /***====================================================================***/
  101. /***                       GENERAL STRUCTURES                           ***/
  102. /***====================================================================***/
  103.  
  104.     /*
  105.      *  WARNING:  Make sure that IDEV_MASK_SIZE is large
  106.      *    enough for the class with the most elements.
  107.      */
  108. #define    IDEV_MASK_SIZE        ((IDEV_MAX_BUTTONS+7)/8)
  109. #define    idevOffset(n)        ((n)/8)
  110. #define    idevMask(n)        (1<<((n)&0x7))
  111. #define    idevSize(n)        (((n)+7)/8)
  112. #define    idevNth(im,n)        ((im)[(n)/8]&(1<<((n)&0x7)))
  113. #define    idevSetNth(im,n)    ((im)[(n)/8]|= (1<<((n)&0x7)))
  114. #define    idevClearNth(im,n)    ((im)[(n)/8]&=~(1<<((n)&0x7)))
  115. #define    idevClearAll(im)    bzero((im),sizeof (im))
  116. #define    idevCopyAll(s,d)    bcopy((s),(d),IDEV_MASK_SIZE)
  117.  
  118.     /*
  119.      * An idevBitVals structure contains a mask bit and a
  120.      * value bit per element of any input class for an input
  121.      * device.   Use an idevBitVals to selectively change or
  122.      * query bit values.
  123.      */
  124. typedef struct _idev_bit_vals {
  125.     unsigned char    mask[IDEV_MASK_SIZE];
  126.     unsigned char    value[IDEV_MASK_SIZE];
  127. } idevBitVals;
  128.  
  129. /***====================================================================***/
  130. /***               IOCTLS TO GET A DESCRIPTION OF A DEVICE              ***/
  131. /***====================================================================***/
  132.  
  133.     /*
  134.      * The IDEVGETDEVICEDESC ioctl accepts and fills in an idevDesc, 
  135.      *      which describes the device as a whole.
  136.      *
  137.      * A device consists of several input and feedback classes 
  138.      *      each of which has 0 or more elements.  An idevDesc
  139.      *    contains a symbolic name for the type of the device
  140.      *    (usually one of the device classes defined by the X input 
  141.      *    extension) a symbolic name for the device, and a count of the 
  142.      *    number of elements of each input class on the device.
  143.      *
  144.      *      Legal input classes are:
  145.      *        Buttons
  146.      *        Valuators 
  147.      *      Legal feedback classes are:
  148.      *        LEDs
  149.      *        String Displays
  150.      *        Integer Displays
  151.      *        Bell
  152.      *
  153.      * In addition, an device has an optional name for the
  154.      *      keymap associated with its buttons.    If the
  155.      *      device has a named keymap, the hasKeymapField is
  156.      *    non-zero.
  157.      */
  158. #define    IDEV_MAX_NAME_LEN    15
  159. #define    IDEV_MAX_TYPE_LEN    15
  160.  
  161. typedef struct _idev_desc {
  162.     char        devName[IDEV_MAX_NAME_LEN+1];
  163.     char        devType[IDEV_MAX_TYPE_LEN+1];
  164.     unsigned short    nButtons;
  165.     unsigned short    nValuators;
  166.     unsigned short    nLEDs;
  167.     unsigned short    nStrDpys;
  168.     unsigned short    nIntDpys;
  169.     unsigned char    nBells;
  170.     unsigned char    flags;
  171. } idevDesc;
  172. #define    IDEV_HAS_KEYMAP        0x01
  173. #define IDEV_HAS_PROXIMITY    0x02
  174. #define IDEV_HAS_PCKBD        0x04
  175.  
  176.     /*
  177.      * QUERY DEVICE COMPONENT DESCRIPTIONS:
  178.      * Description of the specified member of an input class.   If 
  179.      *    all elements in the class have the same characteristics,
  180.      *    the IDEV_SAME bit is turned on in the flags field of the
  181.      *    description.
  182.      * If the IDEV_SET_ALL is set when changing the description of
  183.      * a valuator, all valuators are changed.
  184.      */
  185. #define    IDEV_SAME        (0x8000)
  186. #define    IDEV_SET_ALL        (0x8000)
  187.  
  188.     /* 
  189.      * Use the IDEVGETVALUATORDESC ioctl to get the description of
  190.      *    the valuator specified by dialNum.   IDEVGETVALUATORDESC 
  191.      *    accepts and fills in an idevGetSetValDesc.  An axis must
  192.      *    report absolute values. The resolution field returns the 
  193.      *    resolution of the specified valuator in 'ticks per inch'
  194.      *    (whatever that means).   The minVal and maxVal fields contain 
  195.      *    the minimum and maximum values the device will return.   
  196.      * possibleModes can be one of
  197.      *    IDEV_ABSOLUTE, IDEV_RELATIVE, IDEV_EITHER
  198.      * mode is the current mode and can be one of:
  199.      *    IDEV_ABSOLUTE, IDEV_RELATIVE
  200.      */
  201. typedef struct _idev_valuator_desc {
  202.     unsigned    hwMinRes;
  203.     unsigned    hwMaxRes;
  204.     int        hwMinVal;
  205.     int        hwMaxVal;
  206.     unsigned char    possibleModes;
  207.     unsigned char    mode;
  208.     unsigned short  resolution;
  209.     int        minVal;
  210.     int        maxVal;
  211. } idevValuatorDesc;
  212.  
  213. #define    IDEV_ABSOLUTE        0x0
  214. #define    IDEV_RELATIVE        0x1
  215. #define    IDEV_EITHER        0x2
  216.  
  217. #define    IDEV_SET_RESOLUTION    (0x01)
  218. #define    IDEV_SET_MIN        (0x02)
  219. #define    IDEV_SET_MAX        (0x04)
  220. #define    IDEV_SET_MODE        (0x08)
  221.  
  222. typedef struct _idev_valuator_query {
  223.     short            valNum;
  224.     unsigned short        flags;
  225.     idevValuatorDesc    desc;
  226. } idevGetSetValDesc;
  227.  
  228.  
  229.     /* 
  230.      * Use the IDEVGETKEYMAPDESC ioctl to get the symbolic name of the
  231.      *    default keymap for the specified device.  
  232.      *    IDEVGETKEYMAPDESC accepts and fills in an idevKeymapDesc.  
  233.      *    If the device does not have a keymap, name is "" and the
  234.      *      ioctl fails.   Otherwise, name returns the name
  235.      *    of the keymap.   The only keymap name currently defined
  236.      *    is "SGI Standard" which uses the default key mapping compiled
  237.      *    into the X server.   The X server uses any other name to
  238.      *    look up a file in /usr/lib/X11/input (e.g. "swedish" would
  239.      *    use the keymap specified in /usr/lib/X11/input/swedish.xkm).
  240.      */
  241. #define IDEV_KEYMAP_NAME_LEN    15
  242. typedef struct _idev_keymap_desc {
  243.     char    name[IDEV_KEYMAP_NAME_LEN+1];
  244. } idevKeymapDesc;
  245.  
  246.     /*
  247.      * Use the IDEVGETSTRDPYDESC ioctl to get a description of
  248.      *    the specified string display.   IDEVGETSTRDPYDESC accepts
  249.      *    and fills in an idevStrDpyDesc.   The maxLength field 
  250.      *    returns the maximum length of a displayed string in symbols.  
  251.      *    The symbolSet field returns a symbolic name for the set of 
  252.      *    symbols the string display can show, but no names for 
  253.      *    symbol sets are currently defined.   If all string displays 
  254.      *    in the device have the same length and symbol set,
  255.      *    the allSame field is non-zero;
  256.      */
  257. #define    IDEV_STR_DPY_SYMBOLS_NAME_LEN    15
  258. typedef    struct _idev_str_dpy_desc {
  259.     unsigned short    dpyNum;
  260.     unsigned short    maxLength;
  261.     char        allSame;
  262.     char         symbolSet[IDEV_STR_DPY_SYMBOLS_NAME_LEN+1];
  263. } idevStrDpyDesc;
  264.  
  265.     /*
  266.      * Use the IDEVGETINTDPYDESC ioctl to get a description of
  267.      *    the specified integer display. IDEVGETINTDPYDESC accepts
  268.      *    and fills in an idevIntDpyDesc.   The allSame field is
  269.      *    non-zero if all integer displays on the device have the 
  270.      *    same characteristics.
  271.      *
  272.      * The minValue and maxValue fields specify the minimum and
  273.      *    maximum values the specified display can show.
  274.      * The resolution field specifies the number of digits the 
  275.      *    feedback can display.
  276.      */    
  277. typedef struct _idev_int_dpy_desc {
  278.     unsigned short    dpyNum;
  279.     unsigned char    allSame;
  280.     unsigned char    pad;
  281.     int    minValue;
  282.     int    maxValue;
  283.     int    resolution;
  284. } idevIntDpyDesc;
  285.  
  286. /***====================================================================***/
  287. /***                   IOCTLS TO QUERY DEVICE STATE                     ***/
  288. /***====================================================================***/
  289.  
  290.     /*
  291.      * Use the IDEVGETBUTTONS ioctl to query the state of the device 
  292.      *     buttons.   IDEVGETBUTTONS returns an idevMask.  Each 
  293.      *     bit in the bits field describes a key.  If the bit is
  294.      *     set, the key is down.  Use the idevNth macro
  295.      *     to check the state of a button.
  296.      *
  297.      * Use the IDEVGETVALUATORS ioctl to query the state of one or
  298.      * more device valutors.   IDEVGETVALUATORS accepts and fills
  299.      * in an idevValuatorState.   The "value" array returns the current 
  300.      * values for "nValuators" (max IDEV_VALUATOR_STATE_MAX) device 
  301.      * valuators, starting at firstValuator.
  302.      */
  303.  
  304. #define    IDEV_VALUATOR_STATE_MAX    8
  305. typedef struct _idev_valuator_state {
  306.     unsigned char    firstValuator;
  307.     unsigned char    nValuators;
  308.     unsigned short    pad;
  309.     int        value[IDEV_VALUATOR_STATE_MAX];
  310. } idevValuatorState;
  311. #define    idevValInState(ps,v) (((ps)->firstValuator<=(v))&&\
  312.                 (((ps)->firstValuator+(ps)->nValuators)>(v)))
  313.  
  314.     /*
  315.      * Use the IDEVGETLEDS ioctl to query the state of the device LEDs.
  316.      * IDEVGETLEDS returns an idevMask structure.   Each bit in the
  317.      * bits field corresponds to a device LED; a '1' bit indicates that
  318.      * the LED is lit.   Use the idevNth macro to check the state of
  319.      * an LED
  320.      *
  321.      * Use the IDEVGETSTRDPY ioctl to query the state of a single
  322.      * device string display.   IDEVGETSTRDPY accepts and
  323.      * fills in an idevStrDpyState.   The nDpy field specifies
  324.      * the display to be read, and the string field returns the
  325.      * contents of the display.
  326.      * 
  327.      * The 'on' field is non-zero if the corresponding display is
  328.      * showing anything at all (on), or zero if the display is clear
  329.      * (off).
  330.      */
  331.  
  332. #define    IDEV_STR_DPY_MAX_LEN    62
  333. typedef struct _idev_str_dpy_state {
  334.     unsigned char    nDpy;
  335.     unsigned char    on;
  336.     unsigned short    str_len;
  337.     unsigned short    string[IDEV_STR_DPY_MAX_LEN];
  338. } idevStrDpyState;
  339.  
  340.     /*
  341.      * Use the IDEVGETINTDPYS ioctl to query the state of one or more
  342.      * device integer displays.   IDEVGETINTDPYS accepts and
  343.      * fills in an idevIntDpyState.   The "value" array returns 
  344.      * the currently displayed values for "nDpys" 
  345.      * (max IDEV_INTDPY_STATE_MAX) device integer displays, starting 
  346.      * at firstDpy.
  347.      * 
  348.      * The 'on' field contains a bit for each display whose state
  349.      * is described which indicates whether or not the corresponding 
  350.      * display is showing any value at all.   The least significant
  351.      * bit of 'on' describes firstDpy, bit 1 describes firstDpy+1 and
  352.      * so on.
  353.      */
  354. #define    IDEV_INT_DPY_MAX    8
  355. typedef struct _idev_int_dpy_state {
  356.     unsigned char    firstDpy;
  357.     unsigned char    nDpys;
  358.     unsigned short    on;
  359.     short        value[IDEV_INT_DPY_MAX];
  360. } idevIntDpyState;
  361.  
  362.  
  363. /***====================================================================***/
  364. /***                   IOCTLS TO CHANGE DEVICE STATE                    ***/
  365. /***====================================================================***/
  366.  
  367.     /*
  368.      * Use the IDEVENABLEBUTTONS ioctl to start/stop reporting 
  369.      * events from device buttons.  Use the IDEVENABLEVALUATORS 
  370.      * to start/stop reporting events from device valuators.
  371.      * All ioctls accept an idevBitVals structure.
  372.      *
  373.      * A '1' bit in the mask.bit field of the idevBitVals enables
  374.      * the corresponding valuator or button if the value.bit field
  375.      * is '1' or disables it if the value.bit field is '0'
  376.      * The enabled state of buttons or valuators whose value mask.bit 
  377.      * is '0' is not changed.
  378.      *
  379.      * Use the IDEVSETVALUATORS and IDEVCHANGEVALUATORS ioctls
  380.      * to change the current value of one or more device valuators.
  381.      * Both ioctls accept and fill in an idevValuator struct.
  382.      * The IDEVSETVALUATORS ioctl changes the current value of
  383.      * a valuator to the corresponding value in the values array.
  384.      * The IDEVCHANGEVALUATORS ioctl adds the members of the
  385.      * values array to the current location of the corresponding
  386.      * dials.
  387.      *
  388.      * Use the IDEVSETVALUATORDESC ioctl to change the minimum
  389.      * and maximum possible values or the valuator resolution.
  390.      * IDEVSETVALUATORDESC accepts an idevGetSetValDesc struct.
  391.      * If the IDEV_SET_MIN bit is set in the flags field of the
  392.      * idevValuatorDesc, the minimum bound of the nthVal valuator
  393.      * is changed.  IDEV_SET_MAX and IDEV_SET_MODE control whether
  394.      * or not the maximum bound or event mode are changed.
  395.      *
  396.      * Use the IDEVSETLEDS ioctl to turn LEDs on or off.   Both 
  397.      * ioctls accept an idevBitVals struct, which is declared above.   
  398.      * A '1' bit in the mask.bits field of the idevBitVals turns the 
  399.      * corresponding LED on (corresponding bit in value.bits is '1')
  400.      * off (corresponding bit in the value.bits field is '0').   A '0' 
  401.      * bit in the mask.bits field has no effect on the corresponding 
  402.      * LED.
  403.      * Use the idevClearAll, idevSetNth and idevClearNth macros 
  404.      * to turn bits on or off.   
  405.      *
  406.      * Use the IDEVSETSTRDPY ioctl to change the contents of a
  407.      * string display.   IDEVSETSTRDPY accepts an idevStrDpyState
  408.      * structure (described above).  If the 'on' field is zero,
  409.      * the display is cleared *even if 'string' contains text*.
  410.      *
  411.      * Use the IDEVSETINTDPYS ioctl to change the contents of one
  412.      * or more integer displays.   If a bit in the 'on' field
  413.      * which corresponds to a display is zero, that display is
  414.      * cleared.
  415.      *
  416.      * Use the IDEVRINGBELL ioctl to ring a device bell.  You
  417.      * can specify volume (1-100), pitch, and duration in
  418.      * milliseconds.   You have no guarantee that the device
  419.      * will comply, but it should do the best that it can.
  420.      */
  421. typedef struct _idev_bell_settings {
  422.     int        which;
  423.     unsigned short    volume;
  424.     unsigned short    pitch;
  425.     unsigned int    duration;
  426. } idevBellSettings;
  427.  
  428.     /*
  429.      * Use the IDEVKEYBDCONTROL ioctl to control click volume
  430.      * and key autorepeat (on/off, rate, which keys repeat).
  431.      * Only those values specified in the 'which' field are
  432.      * changed.
  433.      *
  434.      * Use the IDEVPTRCONTROL ioctl to control valuator acceleration,
  435.      * threshold, etc. for *all* valuators on the device.
  436.      * Only those values specified in the 'which' field are changed.
  437.      */
  438. #define    IDEV_KC_SET_CLICK_VOL    0x01
  439. #define    IDEV_KC_SET_REPEAT    0x02
  440. #define    IDEV_KC_SET_REP_DELAY    0x04
  441. #define    IDEV_KC_SET_REP_RATE    0x08
  442. #define    IDEV_KC_SET_LEDS    0x10
  443. #define    IDEV_KC_SET_KEY_REPEAT    0x20
  444. #define    IDEV_KC_SET_KBD_LEDS    0x40
  445. #define    IDEV_KC_SET_ALL        0x3f
  446. #define    IDEV_KC_SET_ALL_X    0x33
  447.  
  448. #define    IDEV_KC_NUM_LOCK    0x01
  449. #define    IDEV_KC_CAPS_LOCK    0x02
  450. #define    IDEV_KC_SCROLL_LOCK    0x04
  451. typedef    struct _idev_kbd_ctrl {
  452.     unsigned short    which;
  453.     unsigned char    clickVolume;
  454.     unsigned char    repeatOn;
  455.     unsigned char    repeatDelay;
  456.     unsigned char    repeatRate;
  457.     unsigned char    kbdleds_mask;
  458.     unsigned char   kbdleds_value;
  459.     unsigned    leds;
  460.     idevBitVals    keyRepeat;
  461. } idevKeybdControl;
  462.  
  463. #define    IDEV_PC_SET_ACCEL_N        0x01
  464. #define    IDEV_PC_SET_ACCEL_D        0x02
  465. #define    IDEV_PC_SET_ACCEL        0x03
  466. #define    IDEV_PC_SET_THRESHOLD        0x04
  467. #define    IDEV_PC_SET_MULTIPLIER        0x08
  468. #define    IDEV_PC_SET_CURVE_FACTOR    0x10
  469. #define    IDEV_PC_SET_CURVE_INFLECTION    0x20
  470. #define    IDEV_PC_SET_ALL_X        0x07
  471. #define    IDEV_PC_SET_ALL            0x3f
  472.  
  473. typedef struct _idev_ptr_ctrl {
  474.     unsigned char    valNum;
  475.     unsigned char    which;
  476.     short        accelNumerator;
  477.     short        accelDenominator;
  478.     short        threshold;
  479.     short        mult;
  480.     short        curveFactor;
  481.     short        curveInflection;
  482. } idevPtrControl;
  483.  
  484.     /*
  485.      * Use the IDEVOTHERCONTROL ioctl to control device parameters
  486.      * specific to some device.   Examples of "other" controls might 
  487.      * include spaceball translation modes or tablet resolution controls.
  488.      * The IDEVOTHERCONTROL ioctl accepts an idevOtherControl structure.   
  489.      * The "name" field is a string (maximum length 15) which identifies 
  490.      * the type of control.   The contents of the "data" field 
  491.      * depend on the type of control, but must be null-terminated and
  492.      * at most 23 bytes.
  493.      *
  494.      * Use the IDEVOTHERQUERY ioctl to query device parameters.
  495.      * The IDEVOTHERQUERY ioctl accepts an idevOtherQuery structure.
  496.      * The "name" field is a string (maximum length 15) which 
  497.      * specifies the control to query.  On return, the data field
  498.      * contains the value requested.
  499.      */
  500.  
  501. #define    IDEV_CTRL_NAME_LEN    15
  502. #define    IDEV_CTRL_DATA_LEN    23
  503. typedef struct _idev_other_control {
  504.     char    name[IDEV_CTRL_NAME_LEN+1];
  505.     char    data[IDEV_CTRL_DATA_LEN+1];
  506. } idevOtherControl,idevOtherQuery;
  507.  
  508.  
  509. #define    IDEV_GEN_NON_PTR_EVENTS    0x2
  510. #define    IDEV_GEN_PTR_X        0x10
  511. #define    IDEV_GEN_PTR_Y        0x20
  512. #define    IDEV_GEN_PTR_EVENTS    (IDEV_GEN_PTR_X|IDEV_GEN_PTR_Y)
  513. #define    IDEV_GEN_ALL_EVENTS    (IDEV_GEN_PTR_EVENTS|IDEV_GEN_NON_PTR_EVENTS)
  514. #define    IDEV_EXCLUSIVE        0x40
  515. #define    IDEV_SILENT        0x80000
  516. typedef struct _idev_ptr_mode {
  517.     unsigned char    mode;
  518.     unsigned char    pad;
  519.     short    xAxis;
  520.     short    yAxis;
  521. } idevPtrMode;
  522.  
  523. #define    IDEV_PB_SET_MIN_X    0x01
  524. #define    IDEV_PB_SET_MAX_X    0x02
  525. #define    IDEV_PB_SET_MIN_Y    0x04
  526. #define    IDEV_PB_SET_MAX_Y    0x08
  527. typedef    struct _idev_ptr_bounds {
  528.     unsigned    which;
  529.     short        minX,maxX;
  530.     short        minY,maxY;
  531. } idevPtrBounds;
  532.  
  533. #define    IDEV_PTR_SET_X        0x10
  534. #define    IDEV_PTR_SET_Y        0x20
  535. #define    IDEV_PTR_SET        (IDEV_PTR_SET_X|IDEV_PTR_SET_Y)
  536. #define    IDEV_PTR_SET_X_VAL    0x40
  537. #define    IDEV_PTR_SET_Y_VAL    0x80
  538. #define    IDEV_PTR_SET_VALS    (IDEV_PTR_SET_X_VAL|IDEV_PTR_SET_Y_VAL)
  539. #define    IDEV_PTR_SET_ALL    (IDEV_PTR_SET|IDEV_PTR_SET_VALS)
  540. typedef struct _idev_ptr_vals {
  541.     unsigned    which;
  542.     short        x;
  543.     short        y;
  544. } idevPtrVals;
  545.  
  546.      /*
  547.      * The IDEVINITDEVICE ioctl initializes the input device.
  548.      * You should initialize whenever you open the device.
  549.      */
  550.  
  551.     /*
  552.      * possible values for 'possible' and 'which'
  553.      *    IDEV_ACCEL -- Accelerate (scale delta by numerator/denominator 
  554.      *            above threshold).
  555.      *    IDEV_SCALE -- scale absolute value by numerator/denominator
  556.      *    IDEV_CURVE -- apply curve to delta before accelerating
  557.      *
  558.      */
  559. #define    IDEV_ACCEL        1
  560. #define    IDEV_SCALE        2
  561. #define    IDEV_CURVE        4
  562.  
  563.     /*
  564.      * flags
  565.      *    IDEV_INVERT -- invert delta or subtract absolute value from
  566.      *    max.
  567.      */
  568. #define    IDEV_INVERT        (1<<0)
  569. typedef struct idev_transform {
  570.     unsigned char    possible;
  571.     unsigned char    which;
  572.     unsigned short    flags;
  573.     short        numerator;
  574.     short        denominator;
  575.     unsigned short    m1;
  576.     unsigned short    cM;
  577.     unsigned short    inflection;
  578.     unsigned short    threshold;
  579. } idevTransform;
  580.  
  581. #define    IDEV_VT_SET_NUMERATOR        0x0001
  582. #define    IDEV_VT_SET_DENOMINATOR        0x0002
  583. #define    IDEV_VT_SET_THRESHOLD        0x0004
  584. #define    IDEV_VT_SET_MULTIPLIER        0x0008
  585. #define    IDEV_VT_SET_CURVE_FACTOR    0x0010
  586. #define    IDEV_VT_SET_CURVE_INFLECTION    0x0020
  587. #define    IDEV_VT_SET_ALL_X        0x0007
  588. #define    IDEV_VT_SET_ALL            0x003f
  589.  
  590. #define    IDEV_VT_SET_TRANSFORM        0x8000
  591. #define    IDEV_VT_SET_FLAGS        0x4000
  592. #define    IDEV_VT_PTR_X            0x0100
  593. #define    IDEV_VT_PTR_Y            0x0200
  594. #define    IDEV_VT_SET_PTR            0x0300
  595. #define    IDEV_VT_SET_PTR_AND_VAL        0x0400
  596. typedef struct _idev_get_set_transform {
  597.     unsigned short    which;
  598.     unsigned short    valNum;
  599.     idevTransform    transform;
  600. } idevGetSetTransform;
  601.  
  602. #ifdef _KERNEL
  603.     /*
  604.      * Helper functions and structures so that device 
  605.      * streams modules don't have to have tons of almost 
  606.      * identical functions.
  607.      */
  608.  
  609. typedef struct idev_info idevInfo;
  610.  
  611.     /*
  612.      * An idevShmiqInfo structure contains everything a streams
  613.      * fuction needs to know about a shmiq device.
  614.      */
  615. typedef struct idev_shmiq_info {
  616.     struct queue        *rq;
  617.     struct queue        *wq;
  618.     struct shmiqlinkid     shmiqid;
  619.     void    (*readData)(idevInfo *info, char *str, int  len);
  620.     int    (*writeIoctl)(idevInfo *info, int cmd,
  621.                 int size, char *data, int *found);
  622. } idevShmiqInfo;
  623.  
  624.     /*
  625.      * An idevValInfo stucture contains everything a streams function
  626.      * needs to know about the valuators of a device.  Each array
  627.      * in an idevValInfo has 'nVal' elements.
  628.      */
  629.  
  630. typedef struct idev_dev_val_info {
  631.     int              nVal;
  632.     int            *sysValue;
  633.     idevValuatorDesc    *desc;
  634.     idevTransform        *transform;
  635.     unsigned char        *active;
  636.  
  637.     unsigned char          mode;
  638. } idevValInfo;
  639.  
  640.     /*
  641.      * An idevPtrInfo stucture contains everything a streams function
  642.      * needs to know to turn valuator data into pointer events.
  643.      */
  644. typedef struct idev_dev_ptr_info {
  645.     short             xAxis,yAxis;
  646.     short             minX,maxX;
  647.     short             minY,maxY;
  648.     short             x,y;
  649.     idevTransform         yTransform;
  650.     idevTransform         xTransform;
  651. } idevPtrInfo;
  652.  
  653.     /*
  654.      * An idevBtnInfo stucture contains everything a streams function
  655.      * needs to know about the buttons of a device.  Each array
  656.      * in an idevBtnInfo has 'nBtn' elements.
  657.      */
  658. typedef struct idev_dev_btn_info {
  659.     int         nBtn;
  660.     unsigned char    *state;
  661.     unsigned char    *active;
  662. } idevBtnInfo;
  663.  
  664.     /*
  665.      *  An idevInfo structure contains fields that are common
  666.      *  to all "idev" devices.
  667.      */
  668. struct idev_info {
  669.     idevShmiqInfo    sInfo;
  670.     idevBtnInfo    bInfo;
  671.     idevValInfo    vInfo;
  672.     idevPtrInfo    pInfo;
  673.     struct termio    *settings;
  674. };
  675.  
  676.     /* 
  677.      * Given a queue, information a device and an idevValuatorState, 
  678.      * idevGenValEvents formats and generates shmiq events.  
  679.      *
  680.      * If the valuator mode is IDEV_GEN_PTR_EVENTS, idevGenValEvents
  681.      * will generate events of type IDEV_PTR_EVENT only. IDEV_PTR_EVENT
  682.      * events contain a button mask with up to five buttons, an X
  683.      * coordinate and a Y coordinate.
  684.      *
  685.      * If the valuator mode is IDEV_GEN_NON_PTR_EVENTS, idevGenValEvents
  686.      * generates events of type IDEV_VAL_EVENT only.   If the valuator
  687.      * mode is IDEV_GEN_ALL_EVENTS, idevGenValEvents generates events of
  688.      * type IDEV_PTR_EVENT for the axes which control the cursor and
  689.      * IDEV_VAL_EVENT events for all axes.   If the IDEV_EXCLUSIVE bit
  690.      * of the mode is set, idevGenValEvents does not generate valuator
  691.      * events for the axes which control the cursor.
  692.      *
  693.      * All shmiq valuator events use absolute coordinates.  The
  694.      * sysValues field in vInfo should contain the current absolute
  695.      * values for each axis.   The idevGenValEvents routine updates
  696.      * vInfo->sysValues with the information from vNew.
  697.      *
  698.      * The idevGenValEvents routine clamps returned valuator positions 
  699.      * to the min and max values specified in vInfo->desc.  The 
  700.      * idevGenValEvents routine sets the QE_CLAMPED bit in the shmiq 
  701.      * events for any axes that it clamps.
  702.      *
  703.      * 'flags' can contain any combination of QE_RESPONSE, QE_MORE_EVENTS,
  704.      * IDEV_VALS_ABSOLUTE, and IDEV_GENERATE_ALL.   
  705.      * If the QE_RESPONSE bit is set in 'flags', idevGenValEvents sets
  706.      * QE_RESPONSE in the flags field of all generated events.   
  707.      * 
  708.      * If IDEV_VALS_ABSOLUTE is set in 'flags' idevGenValEvents uses
  709.      * the values in vNew as absolute valuator positions, 
  710.      * otherwise they are added to the previous valuator position.   
  711.      *
  712.      * Normally, idevGenValEvents generates events only for axes that 
  713.      * change.   If IDEV_GENERATE_ALL is set, idevGenValEvents generates 
  714.      * events for all axes that are specified in vNew and active 
  715.      * in vInfo->active.
  716.      *
  717.      * Normally, idevGenValEvents sets the QE_MORE_EVENTS for all
  718.      * generated valuator events save the last.   If the QE_MORE_EVENTS
  719.      * bit is set in 'flags,' idevGenValEvents sets QE_MORE_EVENTS
  720.      * in the last field too.
  721.      *
  722.      * idevGenValEvents returns zero if it fails, non-zero if it
  723.      * succeeds.  If any of the values were clamped, it sets the 
  724.      * QE_CLAMPED bit in the return value.
  725.      *
  726.      * idevGenValEvent is similar to idevGenValEvents, but it
  727.      * generates a single event from an axis and value that are
  728.      * passed in.
  729.      */
  730. #define    IDEV_VALS_ABSOLUTE    ((unsigned)0x0100)
  731. #define    IDEV_GENERATE_ALL    ((unsigned)0x0200)
  732. #define    IDEV_NO_TRANSFORM    ((unsigned)0x0400)
  733. extern    int    idevGenValEvents(
  734.             idevInfo        *pInfo,
  735.             idevValuatorState    *vNew,
  736.             unsigned         flags);
  737.  
  738. extern    int    idevGenValEvent(idevInfo    *pInfo,
  739.             int             axis,
  740.             int             value,
  741.             unsigned          flags);
  742.  
  743.     /* 
  744.      * idevSetPtrControl sets pointer acceleration parameters for the
  745.      * specified device.
  746.      * idevSetPtr sets ointer acceleration, threshold, multiplier,
  747.      * curve factor and curve inflection for the specified device.
  748.      *
  749.      */
  750. extern    idevTransform idevDfltAccel;
  751. extern    idevTransform idevDfltScale;
  752. extern    int    idevSetPtrCtrl(idevInfo *pInfo,idevPtrControl *ctrl);
  753. extern    int    idevSetPtr(idevInfo *pInfo, idevPtrVals *ctrl);
  754.  
  755.     /*
  756.      * idevGetValDesc queries the min value, max value or resolution of the 
  757.      * specified axis.
  758.      * idevGetValState queries the current system value for the specified
  759.      * axes.
  760.      */
  761. extern    int    idevGetValDesc(idevInfo *pInfo, idevGetSetValDesc *axis);
  762. extern    int    idevGetValState(idevInfo *pInfo, idevValuatorState *vals);
  763.  
  764.     /*
  765.      * Changes the min value, max value or resolution of the 
  766.      * specified axes.
  767.      *
  768.      * If the current value of some axis is outside of the
  769.      * new range, idevSetValDesc clamps the event into the
  770.      * new range and generates an event with the QE_RESPONSE
  771.      * bit set.
  772.      */
  773. extern    int    idevSetValDesc(idevInfo    *pInfo,idevGetSetValDesc *new);
  774.  
  775. extern    int    idevGetTransform(idevInfo *pInfo,idevGetSetTransform *trans);
  776. extern    int    idevSetTransform(idevInfo *pInfo,idevGetSetTransform *trans);
  777.  
  778.     /*
  779.      * Given a queue, information about device buttons, and 
  780.      * a button to change, idevGenBtnEvent formats and generates
  781.      * a shmiq events if the button is active.
  782.      * If the IDEV_BTN_PRESS bit is set in flags, idevGenBtnEvent
  783.      * generates a down event, otherwise it generates an up event.
  784.      * 
  785.      * idevGenBtnEvent checks the current state of the button
  786.      * before generating an event.   If the new event is a
  787.      * state change, idevGenBtnEvent generates the event normally.
  788.      *
  789.      * If the new event is *not* a state change, other bits
  790.      * in flags control event generation.
  791.      * If the IDEV_FAKE_EVENT bit is set, idevGenBtnEvent fakes
  792.      * an event to ensure that the new event is a state change.
  793.      * If the IDEV_FORCE_EVENT bit is set, idevGenBtnEvent generates
  794.      * the new event despite the fact that there is no state change.
  795.      * If neither bit is set, idevGenBtnEvent generates no event.
  796.      * Example:   button 1 is down in bInfo->state, and the device
  797.      *    module calls idevGenBtnEvent for a button 1 press.
  798.      * If IDEV_FAKE_EVENT is set in flags, idevGenBtnEvent generates
  799.      *    "button 1 up" followed by "button 1 down."
  800.      * If IDEV_FORCE_EVENT is set in flags, idevGenBtnEvent generates
  801.      *    "button 1 down."
  802.      * If neither bit is set, idevGenBtnEvents doesn't generate
  803.      *    an event.
  804.      */
  805. #define    IDEV_BTN_PRESS        0x01
  806. #define    IDEV_FAKE_EVENT        0x80
  807. #define    IDEV_FORCE_EVENT    0x40
  808.  
  809. extern    int    idevGenBtnEvent(idevInfo    *pInfo,
  810.             unsigned         btnNum,
  811.             int             flags);
  812.  
  813. extern    int    idevGenBtnEvents(idevInfo    *pInfo,
  814.             unsigned char        *newMask,
  815.             unsigned char        *newState);
  816.  
  817.     /* 
  818.      * The idevSetPtrMode function changes the pointer
  819.      * mode and pointer axes of the device.
  820.      * The idevSetPtrBounds function changes the width and
  821.      * height (maximum X and Y) for QE_PTR_EVENTs from  a
  822.      * device.
  823.      */
  824. extern    int    idevSetPtrMode(idevInfo *pInfo,idevPtrMode *pMode);
  825. extern    int    idevSetPtrBounds(idevInfo *pInfo,idevPtrBounds *pBounds);
  826.  
  827.     /*
  828.      * Given a length (in bytes), a bit array to update and and an 
  829.      * idevBitVals, idevUpdateBitArray changes any bits specified in 
  830.      * new->mask to the corresponding state specified in old->value.
  831.      */
  832. extern    int    idevUpdateBitArray(int nBytes,char *old, idevBitVals *new);
  833.  
  834.     /* 
  835.      * Given information about a device and a termio with the correct
  836.      * line settings, idevChangeLineSettings issues an ioctl to 
  837.      * change the line settings as appropriate.
  838.      */
  839. extern    int    idevChangeLineSettings(idevInfo *pInfo,struct termio *tio);
  840.  
  841. extern    int    idev_rput( register queue_t *rq, mblk_t *mp );
  842. extern    int    idev_wput( register queue_t *wq, register mblk_t *mp );
  843.  
  844. #endif
  845.  
  846. #endif /* IDEV_H */
  847.